package com.hp.gxw.u8.xml;

import com.hp.gxw.u8.dto.U8OrderDeleteParameter;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.io.OutputFormat;

import java.util.HashMap;
import java.util.Map;


public class U8OrderDeleteXml {

	public static String createXML(U8OrderDeleteParameter u8OrderDeleteParameter){
		try {
			Map<String,Object> resultMap = new HashMap<String,Object>();
			// 1、创建document对象
			Document document = DocumentHelper.createDocument();
			// 2、创建根节点rss
			Element ufinterface = document.addElement("ufinterface");
			ufinterface.addNamespace("z", "http://www.w3.org/2001/XMLSchema");
			// 向ufinterface节点添加efserverid属性(U8账套)
			ufinterface.addAttribute("efserverid", u8OrderDeleteParameter.getEfserverid());
			// 向ufinterface节点添加eftype属性(方法：24代表采购入库)
			ufinterface.addAttribute("eftype", u8OrderDeleteParameter.getEftype());
			// 向ufinterface节点添加proc属性(增删改查事件)
			ufinterface.addAttribute("proc", u8OrderDeleteParameter.getProc());
			// 向ufinterface节点添加efdebug属性
			ufinterface.addAttribute("efdebug", "0");
			// 向ufinterface节点添加actions属性,入库后自动审核
			ufinterface.addAttribute("efid", u8OrderDeleteParameter.getEfid());

			OutputFormat format = OutputFormat.createPrettyPrint();
			// 设置编码格式
			format.setEncoding("UTF-8");

			return document.asXML();
		}catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
}
